﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OLTS.DAL;


namespace Framework
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;

    public abstract class BaseFramework<TResult> : BaseClass
    {
        #region Variables

        private TResult _result;

        private bool _executeSuccess = false;

        private decimal _processingTimeInSecond;

        private DateTime _currentDate = DateTime.Now;

        #endregion

        #region Contructor

        public BaseFramework()
        {

        }

        #endregion

        #region Properties

        public TResult Result
        {
            get { return _result; }
            set { _result = value; }
        }

        #endregion

        #region Method

        public override void Execute()
        {
            try
            {

                ExecuteCommand();

                _executeSuccess = true;


            }
            catch (Exception ex)
            {
                _executeSuccess = false;
                WriteErrorLog(ex.ToString());
                throw ex;


            }
            finally
            {
                CrateActivityLog();

            }

        }

        protected void WriteTraceLog(string message)
        {
            //Write log to DB
        }

        protected void WriteErrorLog(string message)
        {
            //Write Error log to DB
        }

        protected virtual void CrateActivityLog()
        {

        }

        protected override abstract void ExecuteCommand();

        #endregion

    }
}
